package com.xiao.train.business.mq;

import com.xiao.train.business.dto.ConfirmOrderMQDto;
import com.xiao.train.business.service.ConfirmOrderService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ConfirmOrderConsumerRabbitMQ {

    @Autowired
    ConfirmOrderService confirmOrderService;

    @RabbitListener(queues = "confirmOrder")
    public void listener(ConfirmOrderMQDto dto) {
        MDC.put("LOG_ID", dto.getLogId());
        log.info("RabbitMQ收到消息：{}", dto);
        confirmOrderService.doConfirm(dto);
    }
}
